package com.androidx.p013lv.mine.model;

import android.content.Context;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.androidx.p013lv.base.bean.UserInfo;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.JsonParams;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.mine.bean.MobileAction;
import org.json.JSONObject;

/* renamed from: com.androidx.lv.mine.model.LoginModel */
public class LoginModel extends ViewModel {
    private MutableLiveData<BaseRes<String>> bindPhoneData;
    private MutableLiveData<BaseRes<String>> codeData;
    private MutableLiveData<BaseRes<MobileAction>> mobileActionData;
    private MutableLiveData<BaseRes<UserInfo>> userInfoData;

    public MutableLiveData<BaseRes<String>> dataCode() {
        if (this.codeData == null) {
            this.codeData = new MutableLiveData<>();
        }
        return this.codeData;
    }

    public MutableLiveData<BaseRes<String>> dataBindPhone() {
        if (this.bindPhoneData == null) {
            this.bindPhoneData = new MutableLiveData<>();
        }
        return this.bindPhoneData;
    }

    public MutableLiveData<BaseRes<MobileAction>> dataAction() {
        if (this.mobileActionData == null) {
            this.mobileActionData = new MutableLiveData<>();
        }
        return this.mobileActionData;
    }

    public MutableLiveData<BaseRes<UserInfo>> data() {
        if (this.userInfoData == null) {
            this.userInfoData = new MutableLiveData<>();
        }
        return this.userInfoData;
    }

    public void travelerLogin(String str, String str2) {
        JSONObject travelerLogin = JsonParams.build().travelerLogin(str, str2);
        HttpUtils.getInsatance().post(UrlManager.getInsatance().travelerLogin(), travelerLogin, new HttpCallback<BaseRes<UserInfo>>("travelerLogin") {
            /* class com.androidx.p013lv.mine.model.LoginModel.C13481 */

            public void onLvSuccess(BaseRes<UserInfo> baseRes) {
                LoginModel.this.userInfoData.setValue(baseRes);
            }
        });
    }

    public void login(String str, String str2, String str3, Context context) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().login(), JsonParams.build().add("mobile", str).add("captcha", str2).add("deviceId", str3).commit(), new HttpCallback<BaseRes<UserInfo>>("login", context) {
            /* class com.androidx.p013lv.mine.model.LoginModel.C13492 */

            public void onLvSuccess(BaseRes<UserInfo> baseRes) {
                LoginModel.this.userInfoData.setValue(baseRes);
            }
        });
    }

    public void mobileAction(String str) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().mobileAction(), JsonParams.build().add("mobile", str).commit(), new HttpCallback<BaseRes<MobileAction>>("mobileAction") {
            /* class com.androidx.p013lv.mine.model.LoginModel.C13503 */

            public void onLvSuccess(BaseRes<MobileAction> baseRes) {
                LoginModel.this.mobileActionData.setValue(baseRes);
            }
        });
    }

    public void bindMobile(final String str, String str2) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().bindMobile(), JsonParams.build().add("mobile", str).add("captcha", str2).commit(), new HttpCallback<BaseRes<String>>("bindMobile") {
            /* class com.androidx.p013lv.mine.model.LoginModel.C13514 */

            public void onLvSuccess(BaseRes<String> baseRes) {
                baseRes.setData(str);
                LoginModel.this.bindPhoneData.setValue(baseRes);
            }
        });
    }

    public void getPhoneCode(String str, Context context) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().getCaptcha(), JsonParams.build().add("mobile", str).commit(), new HttpCallback<BaseRes<String>>("getCaptcha", context) {
            /* class com.androidx.p013lv.mine.model.LoginModel.C13525 */

            public void onLvSuccess(BaseRes<String> baseRes) {
                LoginModel.this.codeData.setValue(baseRes);
            }
        });
    }

    public void cancelHttp() {
        HttpUtils.getInsatance().cancelTag("travelerLogin");
        HttpUtils.getInsatance().cancelTag("login");
        HttpUtils.getInsatance().cancelTag("mobileAction");
        HttpUtils.getInsatance().cancelTag("bindMobile");
        HttpUtils.getInsatance().cancelTag("getCaptcha");
    }
}
